<template>
  <div class="bid-info">
    <h3>
      询价基本信息
      <el-button size="mini" @click="$router.push({name:'RfqEnquiry'})">返回</el-button>
      <el-button size="mini" type="primary" @click="publishCheck('审核')" v-if="infoData.checkStatus===3">审核</el-button>
    </h3>
    <div class="info-div">
      <div class="info-title">
        <span>询价单号 : {{infoData.psNo}}</span>
      </div>
      <!-- <div class="info-text w100"> -->
      <div class="info-text">
        <span class="text-label">项目名称：</span>
        <span class="text-value">{{infoData.psTitle}}</span>
      </div>
      <div class="info-text">
        <span class="text-label">发布状态：</span>
        <span class="text-value" v-if="infoData.publishStatus==1">发布成功 </span>
        <span class="text-value" v-if="infoData.publishStatus==0">未发布 </span>

      </div>
      <div class="info-text">
        <span class="text-label">审核状态：</span>
        <span class="text-value" v-if="infoData.checkStatus==1">已审核 </span>
        <span class="text-value" v-if="infoData.checkStatus==0">未审核 </span>
        <span class="text-value" v-if="infoData.checkStatus== -1">驳回 </span>
        <span class="text-value" v-if="infoData.checkStatus== 4">待审核 </span>
      </div>
      <div class="info-text">
        <span class="text-label">采购组织：</span>
        <span class="text-value">{{infoData.purOrgName}}</span>
      </div>
      <div class="info-text">
        <span class="text-label"> 采购组：</span>
        <span class="text-value">{{infoData.purGroupName}}</span>
      </div>
      <div class="info-text">
        <span class="text-label">品类：</span>
        <span class="text-value">{{infoData.categoryName}}</span>
      </div>

      <div class="info-text">
        <span class="text-label">是否周期采购：</span>
        <span class="text-value" v-if="infoData.isPeriodic==1">是 </span>
        <span class="text-value" v-if="infoData.isPeriodic==0">否 </span>
      </div>
      <div class="info-text">
        <span class="text-label">通知方式：</span>
        <span class="text-value" v-if="infoData.sendNoticeType==1">短信 </span>
        <span class="text-value" v-if="infoData.sendNoticeType==2">邮件 </span>
        <span class="text-value" v-if="infoData.sendNoticeType==3">短息,邮件 </span>
      </div>
      <div class="info-text w100">
        <span class="text-label">招标说明：</span>
        <span class="text-value">{{infoData.notice}}</span>
      </div>
    </div>
    <div class="info-div">
      <div class="info-title">
        <span>询价时间</span>
      </div>
      <div class="info-text w50">
              <span class="text-label">
                  报价截止日期：
              </span>
        <span class="text-value">{{infoData.quoLimitTime}}</span>
      </div>
    </div>
    <div class="info-div">
      <div class="info-title">
        <span>询价物料</span>
      </div>
      <el-table :data="tableData" border>
        <el-table-column label="供货地区" align="center" prop="purOrgName"></el-table-column>
        <el-table-column label="工厂" align="center" prop="factoryName"></el-table-column>
        <el-table-column label="物料编码" align="center" prop="materialCode"></el-table-column>
        <el-table-column label="物料名称" align="center" prop="materialName"></el-table-column>
        <el-table-column label="型号/规格" align="center" prop="materialSpec"></el-table-column>
        <el-table-column label="单位" align="center" prop="stockUnit"></el-table-column>
        <el-table-column label="质保期" align="center" prop="qualityTime"></el-table-column>
        <el-table-column label="采购量" align="center" prop="planQty"></el-table-column>
        <el-table-column label="交期" align="center" prop="deliveryDate"></el-table-column>
        <el-table-column label="备注" align="center" prop="remarks"></el-table-column>
      </el-table>
    </div>
    <div class="info-div">
      <div class="info-title">
        <span>供应商</span>
      </div>
      <el-table :data="venderData" border>
        <el-table-column label="供应商编码" align="center" prop="vendorCode"></el-table-column>
        <el-table-column label="供应商名称" align="center" prop="vendorName"></el-table-column>
        <el-table-column label="地址" align="center" prop="regAddress"></el-table-column>
        <!-- <el-table-column label="未选择原因" align="center" prop="unselectedReason"></el-table-column> -->
      </el-table>
    </div>

    <el-dialog :title="dialogTitle" :visible.sync="checkVisible" class="dialog-form" width="500px">
      <div class="info-text w100">
            <span class="text-label">
                审核意见：
            </span>
        <span class="text-value">
                <el-input v-model="checkData.checkContent" type="textarea"></el-input>
            </span>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="()=>{checkData.checkStatus=1;savePublishCheck();}">通过</el-button>
        <el-button @click="()=>{checkData.checkStatus=-1;savePublishCheck();}" :disabled="!checkData.checkContent">驳回
        </el-button>

        <!-- <el-button type="primary" @click="()=>{checkData.checkStatus=1;checkTrue();}" :disabled="!checkData.checkContent">通过</el-button>
        <el-button @click="()=>{checkData.checkStatus=-1;checkTrue();}" :disabled="!checkData.checkContent">驳回</el-button> -->
      </div>
    </el-dialog>
  </div>
</template>
<script>
  import qs from 'qs';

  export default {
    props: ['stepData'],
    data() {
      return {
        // 定义附件的业务模块和业务动作
        fileData: {
          busAction: "BID_SET_EVA_METHOD",
          tableName: "CT_PS_BID_MAIN_EXT",
          tableId: this.$route.query.id
        },
        checkVisible: false,
        dialogTitle: '',
        fileList: [],
        checkData: {
          checkStatus: 1,
          checkContent: '',
        },

        infoData: {
          psNo: '21412421',
        },
        tableData: [],
        venderData: []
      };
    },
    computed: {
      status() {
        return 1;
        // return this.stepData.bidMainDto.publishStatus===0?1:this.stepData.bidMainDto.checkStatus===0?2:this.stepData.bidMainDto.ruleSubmitStatus===0?3:this.stepData.bidMainDto.ruleCheckStatus===3?4:5;
      }
    },
    mounted() {
      this.infoData = this.stepData.rfqMain;
      this.tableData = this.stepData.rfqItems.rows; //带分页
      this.venderData = this.stepData.rfqVendors;
    },
    methods: {// 自动上传附件后返回附件url和name
      closeDialog() {
        this.checkVisible = false;
      },
      uploadSuccess: function (response, type) {
        //附件上传成功回调
        this.ruleForm[type] = response.id;
      },

      publishCheck(title) {
        this.checkData.checkContent = '';
        this.dialogTitle = title;
        this.checkVisible = true;
      },
      //发布审核
      savePublishCheck() {
        let checkData = {
          "id": this.infoData.id,
          "status": this.checkData.checkStatus,
          "checkOpinion": this.checkData.checkContent
        };
        console.log(1111111111);
        console.log(checkData);
        this.axios.post(this.lib.config.host.rfq + '/ctmgt/rfq/enquiry/check/', checkData).then((res) => {
          if (res.data.success) {
            this.$message.success('审核成功');
            this.$emit('initList');
            this.closeDialog();
            this.infoData = this.stepData.rfqMain;
             //基本信息
            this.axios.post(this.lib.config.host.rfq + '/ctmgt/rfq/enquiry/rfqEnquiry/' + this.$route.query.id).then((res) => {
                this.infoData = res.data;
            })
            .catch(function (error) {
                console.log(error);
            });
          }
        })
          .catch(function (error) {
            console.log(error);
          });
      }
    }
  }

</script>
